/**
 * Created by oneminute on 7/19/14.
 */

var lz = require("../lib/utils/modules")();

function Property(_opts) {
    this.name = this.name || "";
    this.configurable = false;
    this.enumerable = true;
    this.referenced = _opts.referenced || false;
    this.referencedProp = _opts.referencedProp | "_id";
    this._value = _opts.value || null;
}

Property.prototype.set = function(_value) {
    this._value = _value;
};

Property.prototype.get = function() {
    return this._value;
};

Property.prototype.getReference = function() {
    return this[this.referencedProp];
};

function createProperty(_opts) {
    return new Property(_opts);
}

function User() {
    this._name = "unnamed";
}

var UserDesc = {
    "name" : {
        set: function(_value) {
            lz.Logger.info("invoke set name: ", _value);
            this._name = _value;
        },
        get: function() {
            lz.Logger.info("invoke get name: ");
            return this._name;
        },
        configurable: true,
        enumerable: true
    },
    "password" : {
        value: "123456",
        writable: true,
        enumerable: true
    },
    "state" : {
        value: 0,
        writable: false,
        enumerable: true,
        configurable: true
    }
};

var user01 = Object.create(User.prototype, UserDesc);
var obj = Object.create(null);

lz.Logger.info(typeof(user01));
lz.Logger.info(user01 instanceof User);
lz.Logger.info("user01: ", user01);
user01.name = "tom";
lz.Logger.info("user01: ", user01.name);
user01.state = 1;
lz.Logger.info("user01: ", user01);